package org.xinjiang.data.migration.hainan.convert;

import cn.hutool.core.lang.UUID;
import org.mapstruct.Mapper;
import org.xinjiang.data.migration.common.constant.CreateConstant;
import org.xinjiang.data.migration.common.mapstruct.CommonConvertConfig;
import org.xinjiang.data.migration.hainan.entity.CrimeRelationshipsEntity;
import org.xinjiang.data.migration.hainan.entity.DcpgEntity;
import org.xinjiang.data.migration.hainan.entity.FlushLogEntity;
import org.xinjiang.data.migration.hainan.entity.JzdxEntity;
import org.xinjiang.data.migration.hainan.enums.BusTypeEnum;
import org.xinjiang.data.migration.xinjiang.entity.SysAreaFenceEntity;
import org.xinjiang.data.migration.xinjiang.entity.XjAreaEntity;

import java.util.Date;

@Mapper(config = CommonConvertConfig.class)
public abstract class FlushLogConvert {
    public FlushLogEntity convertJzdx(JzdxEntity s, String errorMsg) {
        FlushLogEntity entity = new FlushLogEntity();
        entity.setId(UUID.fastUUID().toString());
        entity.setBusId(s.getId());
        entity.setBusType(BusTypeEnum.矫正对象);
        entity.setParamContent(s.getSqjzrybh());
        entity.setErrorContent(errorMsg);
        entity.setCreateBy(CreateConstant.SYSTEM);
        entity.setCreateTime(new Date());
        return entity;
    }

    public FlushLogEntity convertDcpg(DcpgEntity s, String errorMsg) {
        FlushLogEntity entity = new FlushLogEntity();
        entity.setId(UUID.fastUUID().toString());
        entity.setBusId(s.getId());
        entity.setBusType(BusTypeEnum.调查评估);
        entity.setParamContent(s.getId());
        entity.setErrorContent(errorMsg);
        entity.setCreateBy(CreateConstant.SYSTEM);
        entity.setCreateTime(new Date());
        return entity;
    }

    public FlushLogEntity convertCrimeRelationship(CrimeRelationshipsEntity s, String errorMsg){
        FlushLogEntity entity = new FlushLogEntity();
        entity.setId(UUID.fastUUID().toString());
        entity.setBusId(s.getId());
        entity.setBusType(BusTypeEnum.犯罪类型);
        entity.setParamContent(s.getId());
        entity.setErrorContent(errorMsg);
        entity.setCreateBy(CreateConstant.SYSTEM);
        entity.setCreateTime(new Date());
        return entity;
    }

    public FlushLogEntity convertArea(XjAreaEntity s, String errorMsg){
        FlushLogEntity entity = new FlushLogEntity();
        entity.setId(UUID.fastUUID().toString());
        entity.setBusId(String.valueOf(s.getId()));
        entity.setBusType(BusTypeEnum.地区);
        entity.setParamContent(String.valueOf(s.getId()));
        entity.setErrorContent(errorMsg);
        entity.setCreateBy(CreateConstant.SYSTEM);
        entity.setCreateTime(new Date());
        return entity;
    }

    public FlushLogEntity convertLocArea(SysAreaFenceEntity s, String errorMsg){
        FlushLogEntity entity = new FlushLogEntity();
        entity.setId(UUID.fastUUID().toString());
        entity.setBusId(String.valueOf(s.getId()));
        entity.setBusType(BusTypeEnum.电子围栏);
        entity.setParamContent(String.valueOf(s.getId()));
        entity.setErrorContent(errorMsg);
        entity.setCreateBy(CreateConstant.SYSTEM);
        entity.setCreateTime(new Date());
        return entity;
    }
}
